extends Node2D


onready var tilemap = $World/TileMap

onready var an1 = $"World/俺"
onready var an2 = $"World/俺2"
onready var fx: ColorRect = $"CanvasLayer2/NegativeFX"

func _process(delta: float) -> void:
	fx.rect_position.x = an2.get_node("俺").global_position.x - 500


func _ready() -> void:
	instance_tiles("雨", preload("res://TSCN/物体/雨.tscn"))
	instance_tiles("箱", preload("res://TSCN/物体/箱.tscn"))
	instance_tiles("梯", preload("res://TSCN/物体/梯.tscn"))
	pass
	
func instance_tiles(tile_name: String, scene: PackedScene):
	var id = tilemap.tile_set.find_tile_by_name(tile_name)
	if id == -1: return
	
	for pos in tilemap.get_used_cells_by_id(id):
		var node: Node2D = scene.instance()
		tilemap.add_child(node)
		node.position = tilemap.map_to_world(pos) + tilemap.cell_size / 2
		tilemap.set_cellv(pos, -1)
